package com.vonchenchen.renderer;

import android.content.Context;

/**
 * Created by  on 2021/1/27.
 */
public class CameraEvaluator {

    private long mPtr;

    public static void initContext(Context context){
        CameraEvaNative.initGlobalContext(context);
    }

    public CameraEvaluator(){
        mPtr = CameraEvaNative.createCameraEva();
    }

    public void release(){
        if(mPtr != 0){
            CameraEvaNative.destoryCameraEva(mPtr);
        }
    }

    public void setVideoConfig(VideoConfig config){


    }

    public void setCanvas(RendererCanvas canvas){
        if(mPtr != 0){
            CameraEvaNative.setLocalView(mPtr, canvas.view, canvas.mode.getValue(), canvas.name);
        }
    }

    public int startPreview(){
        if(mPtr != 0){
            return CameraEvaNative.startPreview(mPtr);
        }
        return -1;
    }

    public int stopPreview(){
        if(mPtr != 0){
            return CameraEvaNative.stopPreview(mPtr);
        }
        return 0;
    }
}
